<template>
	<view>
		<van-cell  v-for="item in slst" :key="item.goods_id"  @click="xiang(item.goods_id)" >
			<view slot="title" v-html="item.goods_name">
			</view>
		</van-cell>
	</view>
</template>

<script>
	import http from "../../http/http.js"
	export default {
		data() {
			return {
				slst:[]
			}
		},
		methods: {
			async lishi(id){
				let{data:res}= await http.get('https://api-hmugo-web.itheima.net/api/public/v1/goods/qsearch?query='+id)
				this.slst=res.message
				var newid="<span style='color: red;'>"+id+"</span>"
				this.slst.forEach(item=>{
					item.goods_name=item.goods_name.replace(id,newid)
				})
			},
			xiang(i){
				wx.navigateTo({url:"/pages/xiang/xiang?id="+i})
			}
		},
		onLoad(sc) {
			this.lishi(sc.id)
		}
	}
</script>

<style>

</style>
